package com.tentative.competition.web.controller.schedule.client;

import com.tentative.competition.common.annotation.Anonymous;
import com.tentative.competition.common.core.controller.BaseController;
import com.tentative.competition.common.core.domain.AjaxResult;
import com.tentative.competition.schedule.service.ScheduleAdminService;
import com.tentative.competition.schedule.service.ScheduleNewsInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @auther: Smile Huang
 * @date: 2023/6/26 20:06
 * @desc:
 * @version: 2.0
 */
@Api(tags = "client-大赛动态")
@RestController
@RequestMapping("/client/dynamic")
public class HomeDynamicController extends BaseController {

    @Autowired
    private ScheduleAdminService scheduleAdminService;

    @Autowired
    private ScheduleNewsInfoService newsInfoService;


    @ApiOperation("获取大赛公告")
    @GetMapping(value = "/announcement/{scheduleId}")
    @Anonymous
    public AjaxResult getAnnouncementInfo(@PathVariable("scheduleId") Long scheduleId) {
        return success(scheduleAdminService.getInfo(scheduleId));
    }

    @ApiOperation("获取大赛新闻")
    @GetMapping(value = "/news/{scheduleId}")
    @Anonymous
    public AjaxResult getNewsInfo(@PathVariable("scheduleId") Long scheduleId) {
        return success(newsInfoService.getDynamicInfo(scheduleId,true));
    }
}
